<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        // 算术运算符
        console.log(`1+2 = ${1 + 2}`)
        console.log(`1-2 = ${1 - 2}`)
        console.log(`2*2 = ${2 * 2}`)
        console.log(`2/2 = ${2 / 2}`)

        console.log(`2%2 = ${2 % 2}`)


        // 关系运算符
        console.log(`1 > 2 = ${1 > 2}`)
        console.log(`1 < 2 = ${1 < 2}`)
        console.log(`1 == 2 = ${1 == 2}`)
        console.log(`2 == 2 = ${2 == 2}`)
        console.log(`2 === 2 = ${2 === 2}`)
        console.log(`1 >= 2 = ${1 >= 2}`)
        console.log(`1 <= 2 = ${1 <= 2}`)
        console.log(`1 != 2 = ${1 != 2}`)



        // 逻辑运算符

        // 优先级顺序是！，&& ，||


        // 与短路，如果第一个表达式的值为false，则第2个表达式不会执行

        console.log(`0 && 2 = ${0 && 2}`);          //0

        console.log(`2 && 3 = ${2 && 3}`);          //3



        // 或短路，如果第一个表达式的值是true，则第2个表示的值不会执行，这个特性经常用在“如果没有配置端口，则使用默认值端口”

        console.log(`0 || 2 = ${0 || 2}`);          //2
        console.log(`2 || 3 = ${2 || 3}`);    // 2    

        console.log(`!(2>1) = ${!(2 > 1)}`)

        // 赋值运算符

        console.log(`a = ${a=2}`);
        // 符合运算符

        console.log(`c = ${c=2}`);
        console.log(`c+=2 = ${c+=2}`)
        console.log(`c-=2 = ${c-=2}`)
        console.log(`c*=2 = ${c*=2}`)
        console.log(`c/=2 = ${c/=2}`)

        console.log(`c%=2 = ${c %= 2}`)

        // 一元运算符
        console.log(`d=${d=2}`);
        console.log(d++)
        console.log(`d=${d=2}`);
        console.log(++d)



        // 条件表达式
        let e = 1;
        console.log(`${e>0?"大于0":"小于0"}`);
    </script>
</body>

</html>